package com.luban.cloud.config;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class RegisterApplication implements ApplicationContextAware {

    private static ApplicationContext applicationContext =null;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
         RegisterApplication.applicationContext = applicationContext;
    }

    public static  <T> T getBean(Class<T> t){
        if (applicationContext == null){
            return null;
        }
      return applicationContext.getBean(t);
    }
}
